<!DOCTYPE html>
<html>

<head th:include="cultivateWeb/header :: culHeaderCss">
</head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <link href="../static/css/bootstrap.min.css" rel="stylesheet"> -->
<!--<link type="text/css" href="/css/cultivateWeb/style/my.css" rel="stylesheet">-->
<link type="text/css" href="/css/cultivateWeb/style/news.css" rel="stylesheet">
<link rel="stylesheet" href="/css/cultivateWeb/style/apply.css">
<style>
    @media screen and (max-width: 768px) {
        body {
            font-size: 1rem
        }

    }

    .form_div {
        display: flex;
        justify-content: center;
    }

    .spans_2 {
        width: 140px;
        float: left;
        margin: 20px 0;
        font-size: 16px;
    }
</style>

<body>
<!-- 顶部导航 -->
<header th:include="cultivateWeb/header :: header(true)"></header>
<div style="clear: both"></div>
<div style="background-color: #f7f7f7; ">
    <div class="container">
        <div class="row">
            <div class="layui-container">
                <p style="line-height: 40px">当前位置：<a href="/cultivate/homepage">首页</a> > <a
                        href="/cultivate/my">个人资料</a> > 不需要理由</p>
            </div>
            <hr style="margin: auto auto 40px auto  ;" />
            <section id="info" style="padding:10px;box-sizing: border-box">
                <div style="margin:0 auto;">
                    <div style="clear: both"></div>
                    <form id="formId">
                        <div class="form_div">
                            <label class="span_1" style="margin: 0;">姓名<span
                                    style="color: #d52525">*</span>：</label>
                            <input style="margin: 10px 0;" name="name" type="text" value="" id="name"
                                   class="form-control inp_1" />
                        </div>
                        <div class="form_div">
                            <label class="span_1" style="margin: 0;">学校<span
                                    style="color: #D52525">*</span>：</label>
                            <input style="margin: 10px 0;" type="text" name="school" value="" id="school"
                                   placeholder="" class="form-control inp_1" />
                        </div>
                        <div class="form_div">
                            <label class="span_1" style="margin: 0;">专业<span
                                    style="color: #D52525">*</span>：</label>
                            <input style="margin: 10px 0;" type="text" name="major" value="" id="major"
                                   class="form-control inp_1" />
                        </div>
                        <div class="form_div">
                            <label class="span_1" style="margin: 0;">电话<span
                                    style="color: #D52525">*</span>：</label>
                            <input style="margin: 10px 0;" type="number" name="phone" value="" id="phone"
                                   placeholder="" class="form-control inp_1" />
                        </div>
                        <div class="form_div">
                            <label class="span_1" style="margin: 0;">理由<span
                                    style="color: #D52525">*</span>：</label>
                            <textarea style="margin: 10px 0;" maxlength="400" type="text" id="reason" name="reason"
                                      class="form-control inp_1"></textarea>
                        </div>
                        <div class="form_div">
                            <div class="form-control but_2"  onclick="affirm()"
                            >确认</div>
                        </div>
                    </form>
                </div>
                <div style="clear: both"></div>
            </section>
        </div>
    </div>
    <!-- 分页 -->
</div>
<!-- footer ------------------------------------------------------- -->
<div class="footer" th:include="cultivateWeb/header :: footer"></div>
<script src="/js/layui/layui.js"></script>
<script type="text/javascript" src="/js/mobile.js"></script>
</body>

<script>
    $('#phone').blur(function () {
        var mobiles = $("#phone").val();
        if (!(/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(mobiles))) {
            layer.msg('手机号码填写错误，请填写正确的手机格式');
            return false
        }
    })

    function affirm() {
        var url = location.search;
        var str = url.substr(1);
        var name = $("#name").val();
        var school = $("#school").val();
        var major = $('#major').val();
        var phone = $("#phone").val();
        var reason = $("#reason").val();
        if (name == '') {
            layer.msg("请输入姓名");
            return false
        }
        if (school == '') {
            layer.msg("请输入学校");
            return false
        }
        if (major == '') {
            layer.msg("请输入专业");
            return false
        }
        if (phone == '') {
            layer.msg("请输入联系电话");
            return false
        }
        if (reason == '') {
            layer.msg("请输入理由");
            return false
        }
        $.ajax({
            url: "/certificate/resumeCollect",
            type: "GET",
            data: $('#formId').serialize(),
            beforeSend: function (request) {
                request.setRequestHeader("Authorization", window.localStorage.getItem("token"))
            },
            success: function (res) {
                if (res.code === 0 || res.code === '0') {
                    layer.msg('提交成功', { icon: 1 });
                    if (str.indexOf("2") != -1) {
                        location.href = "/certificate/recoverMock?grade=2";
                    } else if (str.indexOf("1") != -1) {
                        location.href="/certificate/recoverMock?grade=1";
                    } else if (str.indexOf("0") != -1) {
                        location.href="/certificate/recoverMock?grade=0";
                    }
                } else if (res.code === 10000 || res.code === '10000') {
                    // 登录态失效, 重新登录
                    location.href = "/cultivate/cultivateLogins?name=0"
                } else if (res.code === -1 || res.code === '-1') {
                    layer.msg("提交失败，请刷新重试");
                }
            },
            error: function (res) {


            }
        });
    }
</script>

</html>